﻿using System;
using System.Drawing;

using System.Windows.Forms;

namespace Firestarter.DB.Schema.UI
{
    public static class ControlUtilities
    {

        public static Size SmallButtonSize = new Size(23, 27);
        public static Size LargeButtonSize = new Size(120, 32);


        public static PictureButton CreateToolstripButton(string buttonName, string tooltipText, Image defaultImage, Image hoverImage, Image pressedImage, EventHandler eventHandler)
        {
            PictureButton pictureButton = new PictureButton();
            pictureButton.BackgroundImage = defaultImage;
            pictureButton.ButtonImage = defaultImage;
            pictureButton.HoverImage = hoverImage;
            pictureButton.PressedImage = pressedImage;
            pictureButton.Name = buttonName;
            pictureButton.BackgroundImageLayout = ImageLayout.Stretch;

            pictureButton.FlatAppearance.BorderSize = 0;
            pictureButton.FlatStyle = FlatStyle.Flat;
            pictureButton.Size = SmallButtonSize;
            pictureButton.UseVisualStyleBackColor = true;
            pictureButton.FlatAppearance.MouseDownBackColor = Color.Transparent;
            pictureButton.FlatAppearance.MouseOverBackColor = Color.Transparent;
            pictureButton.Click += eventHandler;
            SetupToolTip(pictureButton, tooltipText);
            return pictureButton;
        }


        public static void SetupToolTip(Control control, string text)
        {
            ToolTip toolTip = new ToolTip();
            SetupToolTipDelay(toolTip);
            toolTip.SetToolTip(control, text);
        }

        private static void SetupToolTipDelay(ToolTip toolTip)
        {
            toolTip.AutoPopDelay = 5000;
            toolTip.InitialDelay = 0;
            toolTip.ReshowDelay = 500;
        }
    }
}
